package chapter5;

import java.util.Scanner;

public class InsertNum {
	public static void main(String[] args) {
		int[] nums = new int[6];
		nums[0] = 97;
		nums[1] = 84;
		nums[2] = 75;
		nums[3] = 45;
		nums[4] = 1;
		System.out.println(nums[5]);
		Scanner input = new Scanner(System.in);
		System.out.println("请输入新增成绩：");
		int score = input.nextInt();
		int index = -1;
		for (int i = 0; i < nums.length; i++) {
			if (score > nums[i]) {
				index = i;
				System.out.println("新增成绩的下标是：" + index);
				break;
			} else {
				index = nums.length - 1;
			}
		}
		for (int i = nums.length - 1; i > index; i--) {
			nums[i] = nums[i - 1];
		}
		nums[index] = score;
		System.out.println("插入后的成绩信息是：");
		for (int i = 0; i < nums.length; i++) {
			System.out.print(nums[i] + "\t");
		}
	}
}
